package Version3;

import Version3.Weapon;

public class MonsterHunter{
    private int life;
    private int attack;
    private int exp;
    private int level;
    private double growthRate;
    private String name;
    private String job;
    private Weapon pWeapon;

    public MonsterHunter(Weapon p, String n)
    {
        life=500;
        attack=50;
        exp=0;
        level=1;
        growthRate=1.1;
        pWeapon=p;
        name=n;
        job="";
    }

	public int getLife()
	{
	    return life;
	}

	public boolean isAlive()
	{
	    if(life<=0)
	        return false;
	    else
	        return true;
	}

	public void hurt(int damage)
	{
	    if(life-damage<=0)
	        life=0;
	    else
	        life=life-damage;
	}

	public void levelup()
	{
		double newAttack = attack * growthRate;
	    attack=(int)newAttack;
	    exp=exp-4-level * 1;
	}
	
	public boolean islevelup(int expEarned)
	{
	    exp=exp+expEarned;            
	    if (exp>=4+level*1){
	        levelup();
	        return true;
	    }
	    return false;
	}
	
	public String getName(){
	    return name;
	}

	public int getAttack(){
	    int temp=pWeapon.getAttack();
	    return attack+temp;
	}

	public int getLevel(){
	    return level;
	}

	public String getJob(){
	    return job;
	}

	protected void setLife(int life)
	{ 
		this.life = life;
	}

	protected void setAttack(int attack)
	{   
		this.attack = attack;
	}

	protected void setGrowthRate(double growthRate)
	{   
		this.growthRate = growthRate;
	}
	
	protected void setJob(String job)
	{ 
		this.job = job;
	}
	public String hurtMonster(Monster m, Stage stage)
	{
		int damage;
		damage=stage.computeMHDamage(this, m);
		
		m.hurted(damage);
			
		String s=this.name+ " attack " +m.getName()+ " for " + damage + " life. \n";
if(!m.isAlive())
{
s=s+ m.getName()+ " was dead. " + this.name + " earned "+m.getExp()+ " exp. \n";
if(this.islevelup(m.getExp()))
{
s= s+ this.name + " level Up \n";
}
}
else
s=s + m.getName()+ " now remains " +m.getLife()+ " life.";
return s;
		
	}
}



